package com.atguigu.guli.service.edu.controller.api;

import com.atguigu.guli.common.base.result.R;
import com.atguigu.guli.service.edu.entity.Course;
import com.atguigu.guli.service.edu.entity.Teacher;
import com.atguigu.guli.service.edu.service.CourseService;
import com.atguigu.guli.service.edu.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author:何梦峰
 * @DATE: 2021/3/19 9:54
 */
@CrossOrigin //允许跨域
@Api(description = "首页")
@RestController
@RequestMapping("/api/edu/index")
@Slf4j
public class ApiIndexController {

    @Autowired
    private CourseService courseService;

    @Autowired
    private TeacherService teacherService;

    @ApiOperation("课程与讲师首页数据")
    @GetMapping
    public R index(){
        List<Course> courseList = courseService.selectHotCourse();
        List<Teacher> teacherList = teacherService.selectHotTeacher();
        return R.ok().data("courseList", courseList).data("teacherList", teacherList);
    }

}
